/*
* Copyright (C) 2009-2010 - Roman Kalynchuk
*
* This file is part of REngine.
*
* REngine is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* REngine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with REngine.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __CKEYBOARD_DEVICE_SDL_H__
#define __CKEYBOARD_DEVICE_SDL_H__

#include "SDL/SDL.h"

namespace rengine3d {

	class CKeyboardDeviceSDL: public IKeyboardDevice {
	public:
		CKeyboardDeviceSDL(const string_t name, CInputSystemSDL* inputSys);
		virtual ~CKeyboardDeviceSDL();

		virtual bool Init(void);
		virtual void Shutdown(void);

		virtual void Update(void);

		virtual bool KeyIsDown(keyboardKey_t key);
		virtual bool KeyPressed();

		virtual void OnKeyPress(int key, int action);
		virtual void OnCharPress(int character, int action);

		virtual keyPress_t GetKey(void);

		virtual uint GetModifiers(void);

		virtual string_t KeyToString(keyboardKey_t key);
		virtual keyboardKey_t StringToKey(string_t str);

		virtual inputDeviceType_t GetType(void) { return inputDeviceType_Keyboard; };
		virtual string_t GetName(void)			{ return "CKeyboardDeviceSDL"; };
	private:
		keyboardKey_t SDLToKey(int key);
	private:
		keyEvent_t				m_event;
		std::vector<bool>		m_keys; 
		std::list<keyPress_t>	m_keysPressed;

		char					m_keyBuffer[256];

		CInputSystemSDL*		m_inputSys;

		unsigned int			m_modifier;
	};

}

#endif
